import http from '@/apis/utils/http'
import { Page } from '@/apis/utils/common'
export interface ChatItem {
  content: string
  type: string
  mine: boolean
  avatar: string
  name: string | any
  sendTime: string
}
export interface UserItem {
  id: number
  avatar: string
  mobile: string
  realName: string

  type: string
  sendTime: string
  msgType: string
  content: string
  readStatus: string
  serviceId: number
  servNickname: string | any
  online: boolean
  source: string
}
export interface MessageWrap {
  cid: string
  username: string
  type: string
  msgType: string
  content: string
  mine: boolean
  fromid: number
  toid: number
  timestamp: number
  userAvatar: string
  serviceName: string
  serviceAvatar: string
  source: string
}
export interface SendInfoWrap {
  code: string
  shortMsg: string
  message: MessageWrap
}
export const getHistory = (): Promise<any> => http.get('/app/im/chat/history')
export const getChatUserList = (params: any): Promise<Page<UserItem>> =>
  http.get('/app/im/chat/userlist', { params })
export const getUserHistory = (userId: number): Promise<any> =>
  http.get('/app/im/chat/userhistory', {
    params: {
      userId
    }
  })
export const sendImgApi = async (data: any, type: string): Promise<string> => {
  return await http.post('/app/im/chat/sendImg', data, {
    headers: {
      'Content-Type': type
    }
  })
}
